package com.akw.boot3.core.service;

import com.akw.boot3.core.entity.UserEntity;
import com.akw.boot3.core.event.LoginSuccessEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Service;

@Service
public class AccountService implements ApplicationListener<LoginSuccessEvent> {

    public void addAccountScore(String username, int score) {
        System.out.println("username:" + username + ",score:" + score);
    }

    @Order(3)
    @Override
    public void onApplicationEvent(LoginSuccessEvent event) {
        UserEntity source = (UserEntity) event.getSource();
        addAccountScore(source.getUsername(), 100);
    }
}
